home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: A problem with fprintf
- Date: Tue, 09 Jan 96 20:51:03 GMT
- Organization: none
- Message-ID: <821220663snz@genesis.demon.co.uk>
- References: <4cs8ie$5ru@no-names.nerdc.ufl.edu> <4csdt4$mcn@castle.nando.net> <4cth3m$1c0@yarrow.wt.com.au>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4cth3m$1c0@yarrow.wt.com.au>
- bvarley@yarrow.wt.com.au "bruce varley" writes:
-
- >In a formal sense the debugger is right. 'src' is not the same as a
- >pointer to a string.
-
- I can be formal if you like! :-)
-
- In the original post src was stated to be a 'static array of characters'.
-
- ISO 7.1.1
-
- "A ``pointer to'' a string is a pointer to its initial (lowest addressed)
- character."
-
- ISO 6.2.1.1
-
- "Except [[cases involving sizeof, & and string literal initialiers]] an
- lvalue that has type ``array of type'' is converted to an expression that
- has type ``pointer to type'' that points to the initial element of the
- array object and is not an lvalue."
-
- Put that together and given that the array src holds a string, then
- in the context of the example src evaluates to something that is formally
- a pointer to a string.
-
- :-)
-
- >&src[0] is closer to being formally right,
-
- In the context that means exactly the same thing.
-
- >if src is type char. If the debugger is REALLY finicky, it might go off
- >hunting for the null and spit the dummy if it doesn't find it.
-
- Well, if the debugger can't handle broken code there's not much hope for it!
-
- >One solution is to use pointers. char* is the right way to point to
- >the string to be output.
-
- Luckily src evaluates to a char *
-
- >Not all compilers are this fussy.
-
- And indeed no C compilers are this fussy.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-